<#include "/template/blog/header.ftl">
	<div class="banner border-top-bottom">
		<ul class="carousel">
			<@shishuo_headline_list_tag>
				<#list tag_headline_list as headline>
					<li class="item" style="background:#212e41 url('${BASE_PATH}/${headline.picture}') center no-repeat;height:250px;"></li>
					<#break />
				</#list>
			</@shishuo_headline_list_tag>
		</ul>
	</div>
	<br />
	<br />

	<div class="container">
	<br>
    <div class="dialog" id="mydialog"  style="display: none;width: 30%;margin-left: auto;  margin-right: auto;position:absoulte;z-index:5555;">
	  <div class="dialog-head">
	    <span class="dialog-close close rotate-hover close_div"></span>
	    <strong>提示消息</strong>
	  </div>
	  <div class="dialog-body">
	    下单成功，请等待客服人员与您联系!
	  </div>
	  <div class="dialog-foot">
	    <a href="/user/order/list.htm"><button class="button bg-green">进入订单中心</button></a>
	  </div>
	</div>
    <form class="form-x" action="/user/toBuy.json" method="post" id="orderCart">
    <div class="grid-big">
        <div class="space xm5 xm1-move">
            <h3 class="padding-bottom border-bottom icon-caret-right"> 购买</h3>
            <br>
            <table class="table table-bordered">
            <tbody><tr class=""><th colspan="2">商品</th></tr>
            
            <tr id="cart6767" class="">
            <td width="60">
            <#list product.pictureList as pic>
				<img src="${BASE_PATH}/${pic.url}" width="60" />
				<#break/>
			</#list>
            </td>
            <td class="badge-corner">
                <span class="text-red text-small"></span> <a href="/product/${product.productId}.htm" target="_blank">${product.productName} </a>
                <div class="float-right padding-top" align="right">
                    ¥${product.price} × <span id="buyNum">${num}</span><br>
                    <input type="hidden" name="orderDetails[0].productId" value="${product.productId}">
		            <input type="hidden" name="orderDetails[0].productNum" id="buyNumHidden" value="${num}">
		            <input type="hidden" name="orderDetails[0].productPrice" id="productPrice" value="${product.price}">
                    <button type="button" class="button button-little" onclick="add()">+</button>
                    <button type="button" class="button button-little" onclick="reduce()">-</button>
                </div>
                </td>
            </tr>
            
            <tr class=""><td colspan="2" align="right">总计： ¥<span id="total">${product.price*num}</span><input type="hidden" name="totalprice" id="totalprice" value="${product.price*num}"></td></tr>
            </tbody></table>
            <br>
        </div>
        
        <div class="space xm5 xm1-move">

            <h3 class="padding-bottom border-bottom icon-caret-right"> 收货信息</h3>
            <br>
            <div class="form-group">
                <div class="label"><label for="receive">收件人</label></div>
                <div class="field">
                  <input type="text" class="input" id="linkman" name="linkman" value="" size="30" placeholder="收件人的真实姓名" data-validate="required:收件人不能为空">
                </div>
            </div>
            <div class="form-group">
                <div class="label"><label for="address">地址</label></div>
                <div class="field">
                  <input type="text" class="input" id="address" name="address" value="" size="30" placeholder="详细的收件地址" data-validate="required:收件地址不能为空">
                </div>
            </div>
            <div class="form-group">
                <div class="label"><label for="postcode">邮编</label></div>
                <div class="field">
                  <input type="text" class="input" id="zipCode" name="zipCode" value="" size="30" placeholder="收件地址邮编" data-validate="required:邮编不能为空,number:邮编必须为数字">
                </div>
            </div>
            <div class="form-group">
                <div class="label"><label for="tel">电话</label></div>
                <div class="field">
                  <input type="text" class="input" id="mobile" name="mobile" value="" size="30" placeholder="收件人手机或电话号码" data-validate="required:电话不能为空,tel:电话格式有误">
                </div>
            </div>
            <div class="form-group">
                <div class="label"><label for="readme">备注</label></div>
                <div class="field">
                  <textarea class="input" id="remark" name="remark" rows="2" placeholder="备注信息"></textarea>
                </div>
            </div>
            <div class="padding-top" align="right"><button class="button bg-main" id="orderCartBtn"> 立即下单 </button></div>
        </div>
    </div>
   
    <br>
	</form>
</div>
</div>
<script type="text/javascript">
function add() {
	var num= parseInt($("#buyNumHidden").val()) + 1;
	$("#buyNumHidden").val(num);
	$("#buyNum").text(num);
	$("#total").text($("#productPrice").val()*num);
	$("#totalprice").val($("#productPrice").val()*num);
	
};
function reduce(ids) {
	if (parseInt($("#buyNumHidden").val())>1){
    	var num= parseInt($("#buyNumHidden").val()) - 1;
		$("#buyNumHidden").val(num);
		$("#buyNum").text(num);
		$("#total").text($("#productPrice").val()*num);
		$("#totalprice").val($("#productPrice").val()*num);
	}
}
$("#orderCartBtn").click(function(){
	$('#orderCart').ajaxForm({
		dataType : 'json',
		success : function(data) {
			if (data.result) {
				$("#mydialog").css("display","block");
			}else{
				alert("下单失败!");	
			}
		}
	});
});
$(".close_div").click(function(){
	$("#mydialog").css("display","none");	
});
</script>
	<#include "/template/blog/footer.ftl">